<?php
function manga_render_desktop_item_small_right($row){
														
														$str='<div class="each-small-item item-even">
														<a class="small-image-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="img-right" src="'.mangaf1_gglink($row['hinhanh']).'" alt="" /></a>
														<a class="small-title-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a>
														<span class="featured-item-new-chapt"><a href="'.str_replace('http://manga24h.com','http://truyencuatui.info/truyentranh',$row['ep_moinhaturl']).'">'.$row['ep_moinhat'].'</a></span>
                                                        <div class="small-item-group">'.$row['nhomdich'].'</div>
														<div class="clr"></div>
													</div>';
													return $str;
}
function manga_render_desktop_item($row){
			$str='<div class="col-md-15 col-sm-15 col-lg-15 col-xs-15">
										<div class="featured-item">
											<a href="'.mangaf1_url_manga($row['id'],$row['alias']).'" class="wrap-featured-item-img"><img class="featured-item-img lazy"
												data-original="'.gglink($row['hinhanh']).'"  alt="" /></a>
												
											<h4>
												<a href="'.mangaf1_url_manga($row['id'],$row['alias']).'" title="'.$row['name'].'">'.$row['name'].'</a>
												<span class="paragraph-end"></span>
											</h4>
											<span class="featured-item-new-chapt"><a href="'.str_replace('http://manga24h.com','http://truyencuatui.info/truyentranh',$row['ep_moinhaturl']).'" title="'.$row['name'].' '.$row['ep_moinhat'].'">'.$row['ep_moinhat'].'</a>
											<span class="paragraph-end"></span>
											</span>
											
										</div>
									</div>';
			return $str;
}
function manga_render_desktop_items($data){
	$num=count($data);
	$rows=ceil($num/5);
		for($i=0;$i<$rows;$i++){
				$j=$i*5;
				$dt=array_slice($data,$j,5);
				$str.='<div class="panel-featured-row">';
				foreach($dt as $row){
						$str.=manga_render_desktop_item($row);
				}
				$str.='<div class="clr"></div>';
				$str.='</div>';
		}
	return $str;			
}
function manga_render_desktop_slide($data,$alias,$max,$title, $link = "#"){
?>
			<div class="my-panel" id="<?php echo $alias; ?>-panel">
		          
                <input type="hidden" id="<?php echo $alias; ?>-slider-total-page" name="<?php echo $alias; ?>-slider-total-page" value="<?php echo $max; ?>" />
                <input type="hidden" id="<?php echo $alias; ?>-slider-current-page" name="<?php echo $alias; ?>-slider-current-page" value="1" />
                
                <div class="panel-title">
                                        <a href="<?php echo $link; ?>" class="panel-title-a"><?php echo $title;?></a> <span
                                            class="panel-title-bg-after"></span>
                                            <p class="panel-page" id="<?= $alias ?>-show-current-page">1</p>
                </div>
            
            
            <button type="button" class="btn btn-default slide-btn slide-btn-left" id="<?php echo $alias; ?>-btn-slider-prev" data-rel="<?php echo $alias; ?>"><i class="fa fa-arrow-circle-left fa-lg"></i></button>	
			<button type="button" class="btn btn-default slide-btn slide-btn-right" id="<?php echo $alias; ?>-btn-slider-next" data-rel="<?php echo $alias; ?>"><i class="fa fa-arrow-circle-right fa-lg"></i></button>
            
  		
                <div  id="<?php echo $alias; ?>-wrapper" class="slider-wrapper" data-href="1">
                    <div class="wrap-loading" id="wrap-<?php echo $alias; ?>-loading" style="display: none;">
                            <span class="loading" id="<?php echo $alias; ?>-loading"><img alt="loading" src="public/images/loading11.gif"></span><br>
                    </div>
                            
                    <div id="<?php echo $alias; ?>-content-slide-1" class="<?php echo $alias; ?>-content">
                        <?php echo manga_render_desktop_items($data); ?>
                    </div> <!-- End of $alias-content -->
                
                </div> <!-- End of $alias-wrapper -->
            </div> <!-- End my panel class -->
<?php }
 function manga_render_desktop_update($data){
 ?>
              <?php
			  $str='';
			  foreach ($data as $row)
				   {?>
                 <?php  if($row['ngay']==date('Y-m-d')){
                 			 $str.='<div class="panel-update-date pull-right">';
										$str.='<div class="panel-update-date-before pull-left"></div>';
										$str.='<div class="panel-update-date-content pull-left">Hôm nay '.date('d/m/Y').' </div>';
									$str.='</div>';
                  		 }else{   
							 $str.=' <div class="panel-update-date pull-right">';
										$str.='<div class="panel-update-date-before pull-left"></div>';
										$str.='<div class="panel-update-date-content pull-left">'.time_ago($row['ngay']).'</div>';
									$str.='</div>';
				 
				 		 }
					
				  $str.='<table class="table panel-update-item">';	
				  		// 2 ITEM MOT ROW
				  
				  				 $num=count($row['data']);
								 $rows=ceil($num/2);
								 $j=1;
								for($i=0;$i<$rows;$i++){
									$k=$i*2;
								
									$dt=array_slice($row['data'],$k,2);
								
								
									if($j % 2 == 0)
											$classRow = 'item-even';
									else
											$classRow = 'item-odd';
									 $str.='  <tr class="panel-update-each-item panel-even '.$classRow.'">';
				  
				  	
				  					$num_td=count($dt);
									foreach($dt as $row1){	
									$str.='		<td class="panel-update-each-item-title">';
												$str.='<div style="border: 2px solid #eee; margin-right: 5px; float: left; width: 40px; height: 60px; overflow:hidden;"><img class="manga_image_update lazy" src="'.mangaf1_picasa_link($row1['hinhanh'],60).'" alt="'.$row1['name'].'" /> </div>
												 <a class="tooltip-hover manga-name" href="'.$row1['mgurl'].'">'.$row1['name'].'</a>';
												
											
												
												
												
												$str.='<div class="tooltip-content">';
												$str.='<img class="tooltip-content-image" data-original="'.mangaf1_picasa_link($row1['hinhanh'],150).'" alt="" />';
												$str.='<a class="tooltip-content-title" href="'.mangaf1_url_manga($row1['id'],$row['alias']).'">'.$row1['name'].'</a>';
												$str.='<p class="tooltip-content-desc">'.$row1['gioithieu'].'</p>';
												$str.='<p class="tooltip-content-theloai"><span>Thể loại: </span>: '.$row1['theloai'].'</p>';
												$str.='</div>';
												 if($row1['hot']==1){$str.=' <span class="panel-label panel-hot">HOT</span>';} 
													 if($row1['new']==1){$str.='<span class="panel-label panel-new">NEW</span>';}
												
												$str.='<Br/><a class="manga-chap" href="'.$row1['chapurl'].'">'.$row1['index_show'].'</a>';
												if($row1['status']!=''){
												$str.='<Br/><span class="panel-update-each-item-status"><i class="fa fa-quote-left"></i>'.$row1['status'].'<i class="fa fa-quote-right"></i></span>';				
												}
												
													
									$str.='	</td>';
																			
              
                   					}  //End of foreach item 
									
										if($num_td==1){$str.='<td></td>';}
									
										$str.='</tr>';
										$j++;
									
								} //End foreach 2 item 1 lan
                      $str.='</table>';       
                   
                 
				   } // End of foreach head
				   
				   return $str;
			
 } //End of manga render update
 
 
function manga_render_desktop_manga_detail_box($data){?>
	 	<div class="row detail-info" id="manga-detail-info" xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate">
							<h1 property="v:itemreviewed"><?php echo $data['name'] ?></h1>
							<div class="col-md-12 box" style="padding: 0px 10px;">
							<?php if($_SESSION['mobile']==0){ ?>
								<ul class="breadcrumb breadcrumb_manga" xmlns:v="http://rdf.data-vocabulary.org/#" style="margin-bottom:10px">
							<?php
							}else{ echo '<ul class="breadcrumb" xmlns:v="http://rdf.data-vocabulary.org/#">';
							}?>
							<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="<?php echo HOME; ?>"><i class="fa fa-home"></i> Home</a></li>
							<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="<?php echo MANGA_URL; ?>">Truyện tranh</a></li>
							<?php 
								$theloaiEx = explode(',', $data['theloai']);
								$theloaiName = $theloaiEx[0];
								$theloaiAlias = khongdau($theloaiEx[0]);
							?>
							<!-- <li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="<?php echo MANGA_URL . $theloaiAlias . '.html' ?>"><?= $theloaiName; ?></a></li> -->
							<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="<?php echo MANGA_URL  . $data['id'].'/' . $data['alias'] . '.html'; ?>"><?= $data['name']; ?></a></li>
				
							</ul>
							</div>
							<div class="col-md-3 col-xs-12 col-lg-3 col-sm-6 detail-info-image">
								<img src="<?php echo gglink($data['hinhanh']) ?>" class="img-rounded img-responsive" alt="<?php echo $data['name'] ?>" />
								<?php
								if($data['is_followed'] == false):
								?>
								<button class="btn follow-btn follow-story follow-manga-btn"><i class="fa fa-bookmark"></i> Theo dõi truyện<p class="follow-info"><?= $data['follows'] > 0 ? $data['follows'] : 0 ?> lượt theo dõi</p></button>
								<?php else: ?>
								<button class="btn follow-btn unfollow-story follow-manga-btn unfollow-btn"><i class="fa fa-ban"></i> Bỏ theo dõi<p class="follow-info"><?= $data['follows'] > 0 ? $data['follows'] : 0 ?> lượt theo dõi</p></button>
								<?php endif; ?>
								<div style="height:10px"></div>
							</div>
							
							<div class="col-md-6 col-xs-12 col-lg-6 col-sm-6 detail-info-info">
                            	<?php if($_SESSION['mobile']==0){?>
								<div role="tabpanel" class="detail-tab" id="manga-detail-tab">
									<div class="">
										<ul class="nav nav-pills">
											<li role="presentation" class="active"><a data-toggle="tab" href="#manga-detail-tab-info">Thông tin</a></li>
										
											<li role="presentation"><a data-toggle="tab" href="#manga-detail-tab-tag">Từ Khóa</a></li>
										</ul>
									</div>
									
									<div class="tab-content">
										<div class="tab-pane active fade in" id="manga-detail-tab-info">
											<table class="table">
												<tr>
													<td class="detail-info-label">Thể loại:</td>
													<td class="detail-info-content" id="detail-info-category"><?php echo $data['theloai2']['2']; ?></td>
												</tr>
												<tr>
													<td class="detail-info-label">Tác giả:</td>
													<td class="detail-info-content" id="detail-info-author"><?php echo $data['tacgia']; ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Tình trạng:</td>
													<td class="detail-info-content"><?php echo $data['tinhtrang-text']; ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Nguồn:</td>
													<td class="detail-info-content"><?php if($data['nguon']!=''){ echo mangaf2_get_manga_nguon($data['nguon']);}else{ echo "Đang cập nhật ...";} ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Lượt xem:</td>
													<td class="detail-info-content"><?php echo $data['views']; ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Ngày đăng:</td>
													<td class="detail-info-content"><?php echo time_ago($data['upload_time']); ?></td>
												</tr>
                                                <tr>
													<td colspan="2" style="background-color:#fefefe; padding: 10px; font-size: 17px;"><?php 
														if($data['noidung']==''){$content_show = $data['gioithieu'];}else{$content_show = $data['noidung'];}
															echo "<small>".$content_show."</small>";
														?>
                       								 </td>
													
												</tr>
											</table>
										</div>
									
										
										<div class="tab-pane fade in" id="manga-detail-tab-tag">
											<?php echo $data['data_tags']; ?>
        									 <?php echo $data['tag3']; ?>
										</div>
									</div>
								</div> <!-- End manga-detail-tab -->
                                <?php }else{
									//Neu la mobile thi ko can tab dau
									?>
                                <table class="table">
												<tr>
													<td class="detail-info-label">Thể loại:</td>
													<td class="detail-info-content" id="detail-info-category"><?php echo $data['theloai2']['2']; ?></td>
												</tr>
												<tr>
													<td class="detail-info-label">Tác giả:</td>
													<td class="detail-info-content" id="detail-info-author"><?php echo $data['tacgia']; ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Tình trạng:</td>
													<td class="detail-info-content"><?php echo $data['tinhtrang-text']; ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Nguồn:</td>
													<td class="detail-info-content"><?php if($data['nguon']!=''){ echo mangaf2_get_manga_nguon($data['nguon']);}else{ echo "Đang cập nhật ...";} ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Lượt xem:</td>
													<td class="detail-info-content"><?php echo $data['views']; ?></td>
												</tr>
												
												<tr>
													<td class="detail-info-label">Ngày đăng:</td>
													<td class="detail-info-content"><?php echo time_ago($data['upload_time']); ?></td>
												</tr>
                                                <tr>
													<td colspan="2" style="background-color:#fefefe; font-size: 13px; padding: 10px;"><?php 
														if($data['noidung']==''){$content_show = $data['gioithieu'];}else{$content_show = $data['noidung'];}
															echo "<small>".$content_show."</small>";
														?>
                       								 </td>
													
												</tr>
											</table>
                                <?php }?>
              
							</div> <!-- End col-md-6 -->
							
							<div class="col-md-3 col-xs-12 col-lg-3 col-sm-12 detail-info-metadata">
							<p class="rating-count"><span property="v:count"><?php echo $data['rate_count'] ?></span> đánh giá</p>
								<div id="wrap-rating" class="rating" rel="v:rating">
                                
                                	
                                	<?php 
                                	$max = $data['rate_average'];
									if($max > 5){$max=5;}
									 ?>
									 
									<div typeof="v:Rating">
                                	<div id="rating"style="margin: 0px auto;" class="basic" data-id="1"></div>
                                	
					   				<span>
						   				<p class="rating-point">
						   					<span property="v:average"><?php echo $max; ?></span>/<span property="v:best">5</span>
						   					<span style="display: none" property="v:worst">0</span> 
	         							</p>
	         						</span>
	         						
	         						
	         						
         							<p style="display: none; margin-top: 3px; margin-bottom: 3px;" id="rate_message"></p>
         							
         							<p class="like-info" style="margin-bottom: 3px;">Hãy like truyện để ủng hộ <?= DOMAIN_NAME; ?> cùng với nhóm dịch nhé</p>
         							<!-- Go to www.addthis.com/dashboard to customize your tools -->
									<div class="addthis_native_toolbox" style="text-align:center"></div>
         							<p class="comment-info">Viết bình luận cho truyện</p>
         							</div>
         							<script type="text/javascript">
         							rateDisable = false;
									if($.cookie('ranime_<?php echo $data['id']; ?>') == '1'){
					
										rateDisable = true;
									}
         							$(".basic").jRating({
										bigStarsPath : 'public/images/stars.png', // path of the icon stars.png
										smallStarsPath : 'public/images/small.png', // path of the icon small.png
										type:"big",
										length : 5,
										decimalLength : 1,
										isDisabled: rateDisable,
										step: true,
										nbRates : 3,
										rateMax : 5,
										showRateInfo:false,
										phpPath : '<?= HOME; ?>index.php?module=ajax&act=manga&opt=rating&rating=1&case=anime&id=<?= $data['id']; ?>',
										
										onSuccess : function(data){
											
											if(data){
												if(data.type == 'success'){
													
													classMsgRating = 'rate_success';
													$.cookie('ranime_<?php echo $data['id']; ?>', '1', { expires: 30 });
												}else if(data.type == 'error'){
													classMsgRating = 'rate_error';
												}
												
												$('#rate_message').html('<p class="'+classMsgRating+'">'+data.message+'</p>');
												$('#rate_message').slideDown('normal').delay(3000).slideUp('normal');
											}
											
										  },
										
									});
								 
								</script>
                                  <script type="text/javascript">
                                  $(document).ready(function(){

  									$('.detail-info-image').on('click', '.unfollow-story', function(e){
  										e.preventDefault();
  										username = '<?= $_SESSION['user']['username']; ?>';
  										if(!username){
  											//window.location.href = '<?= LOGIN ?>';
  											popupMessage('Chưa Đăng Nhập', ['Hãy đăng nhập để có thể theo dõi truyện này'], 'alert-danger');
  											return;
  										}
  										anime_id = '<?= $data['id']; ?>';
  										username = '<?= $_SESSION['user']['username']; ?>';
  										$.ajax({
  											url: 'index.php?module=ajax&act=manga&opt=follow_story&unfollow_story=1',
  											type: 'POST',
  											data: {anime_id: anime_id, username: username},
  											success: function(data){
  												if(data) newData = $.parseJSON(data);
  												if(newData.error){
  													popupMessage('Lỗi', [newData.error], 'alert-danger');
  												}else if(newData.message){
  													popupMessage('Thành công', ["Bạn đã hủy theo dõi truyện này thành công"], 'alert-success');
  													$('.unfollow-story').remove();
  													$('.detail-info-image').append('<button class="btn follow-btn follow-story follow-manga-btn"><i class="fa fa-bookmark"></i> Theo dõi truyện<p class="follow-info"><?= $data['follows'] > 0 ? $data['follows'] : 0 ?> lượt theo dõi</p></button>');
  													
  												}
  											},
  										});
  									});
  							
  									$('.detail-info-image').on('click', '.follow-story', function(e){
  										e.preventDefault();
  										username = '<?= $_SESSION['user']['username']; ?>';
  										if(!username){
  											//window.location.href = '<?= LOGIN ?>';
  											popupMessage('Chưa Đăng Nhập', ['Hãy đăng nhập để có thể theo dõi truyện này'], 'alert-danger');
  											return;
  										}
  										anime_id = '<?= $data['id']; ?>';
  										username = '<?= $_SESSION['user']['username']; ?>';
  										
  										$.ajax({
  											url: 'index.php?module=ajax&act=manga&opt=follow_story&follow_story=1',
  											type: 'POST',
  											data: {anime_id: anime_id, username: username},
  											success: function(data){
  												if(data) newData = $.parseJSON(data);
  												if(newData.error){
  													popupMessage('Lỗi', [newData.error], 'alert-danger');
  												}else if(newData.message){
  													popupMessage('Thành công', ["Bạn đã đăng ký theo dõi Manga này thành công"], 'alert-success');
  													$('.follow-story').remove();
  													$('.detail-info-image').append('<button class="btn follow-btn unfollow-story follow-manga-btn unfollow-btn"><i class="fa fa-ban"></i> Bỏ theo dõi<p class="follow-info"><?= $data['follows'] > 0 ? $data['follows'] : 0 ?> lượt theo dõi</p></button>');
  												}
  											},
  										});
  									});
  							
  									
  							
  									
  							
  								});
							</script>
         						 </div> <!-- End wrap rating -->
							</div>
							<div class="clr"></div>
					  <?php 
						if($data['thongbao']!=''){
                  		 	echo " <div class='head_title'>    Thông Báo  </div>";
                 			echo '<div style="padding:10px"> '.$data['thongbao'].'</div>';
                       }?> 
                        
                       <div class='head_title'>   Đánh Gía Truyện   	 </div>  
                       <!-- Content danh gia -->
                       
                       <!-- End content danh gia -->
                       </div>	<!-- End of detail-info -->
                        <?php
 
 }
 
 function manga_render_chapter($data,$alias=''){
 $str='';
              
                
                								$str.='<div class="wrap-chapt-chosen">';
												$str.='<div class="col-md-6">';
		                            $str.=' <select class="form-control input-large chapt-chosen" onchange="location.href=this.value" >';
                                                        $str.='<option>Chọn Nhanh Chap</option>';
                                                     
                                                          if(count($data)>0)
                                                          foreach ($data as $row)
                                                         {
                                                        $str.='<option value="'.mangaf1_url_manga_episode($row['id'],$row['seourl']).'">'.str_ireplace('chapter','Chap',$row['ten']).'</option>';
                                                          }	
                      							 $str.=' </select>';
												$str.='</div>';
												$str.='<div class="col-md-6 wrap-chapt-chosen-info">';
                                                   if(count($data)>0){ $row=$data[0];
													$str.='<p class="chapt-chosen-info">Chương mới nhất:&nbsp;&nbsp; <span><a href="'.mangaf1_url_manga_episode($row['id'],$row['seourl']).'">'.str_ireplace('chapter','Chap',$row['ten']).'</a></span>  / '.time_ago($row['ngaythem']).'</p>';
												 }
												
												$str.='</div>';
												$str.='<div class="clr"></div>';
                                                if($_SESSION['mobile']==0){
                			$str.='<table class="table chapt-table">';
													$str.='<thead>';
														$str.='<tr>';
															$str.='<th>Tên chapter</th>';
															$str.='<th class="hidden-xs">Ngày đăng</th>';
															$str.='<th class="hidden-xs">Lượt xem</th>';
														$str.='</tr>';
													$str.='</thead>';
													$str.='<tbody>';
					 $j=1;  
				   if(count($data)>0){
					   foreach ($data as $row)
					   {
						 if($j%2==0){$str.='<tr class="item-odd">'; }else{$str.='<tr class="item-even">'; }
		 
								  $str.='<td> <a  href="'.mangaf1_url_manga_episode($row['id'],$row['seourl']).'">'.str_ireplace('chapter','Chap',$row['ten']).'</a></td>';
								  $str.=' <td class="hidden-xs"><span>'.time_ago($row['ngaythem']).'</span></td>';
								   $str.='<td class="hidden-xs"> <span> '.$row['solanxem'].'</span></td>';
								 $str.='</tr>';
									
					   
					 
					   	$j++;
					   }
				   }else{
					   $str.=' <tr>';
                   	 $str.='<td colspan="3" style="width: 100%; text-align:center;"><h3 class="alert alert-warning" style="font-weight: lighter">Đang chờ cập nhật</h3></td>';
                    $str.='</tr>';
				   }
                      $str.='</table>';
                       }else{//End session ko phai mobile
					 $str.='<table class="table chapt-table">';
													$str.='<thead>';
														$str.='<tr>';
															$str.='<th>Tên chapter</th>';
															$str.='<th >Ngày đăng</th>';
														
														$str.='</tr>';
													$str.='</thead>';
													$str.='<tbody>';
					 $j=1;  
				   if(count($data)>0){
					   foreach ($data as $row)
					   {
						 if($j%2==0){$str.='<tr class="item-odd">'; }else{$str.='<tr class="item-even">'; }
		 
								  $str.='<td> <a  href="'.mangaf1_url_manga_episode($row['id'],$row['seourl']).'">'.str_ireplace('chapter','Chap',$row['ten']).'</a></td>';
								  $str.=' <td class="hidden-xs"><span>'.time_ago($row['ngaythem']).'</span></td>';
								 $str.='</tr>';
									
					   
					 
					   	$j++;
					   }
				   }else{
					    $str.=' <tr>';
                   	 $str.='<td colspan="3"><h3 class="alert alert-warning">Đang chờ cập nhật</h3></td>';
                    $str.='</tr>';
					    }
                        $str.='</table>';
                      
					  }// End session la mobile
					                             
                    $str.=' </div> ';                            
														
  		return $str;		
 
 
 }
 
 
function manga_render_related_manga($data){
		$str= "<div class='list-group related-manga'>";
										$j=1;
									foreach($data as $row){
										if($j%2==0){
											   $str.='<div class="each-small-item item-even">';
										}else{
												$str.='<div class="each-small-item item-odd">';
										}			
												$str.='<div class="row "><div class="col-md-7">';
													$str.='	<a class="small-image-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="img-right lazy" data-original="'.$row['hinhanh'].'" alt="" /></a>
														<a class="small-title-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a>
														<span class="featured-item-new-chapt"><a href="'.str_replace('http://manga24h.com','http://truyencuatui.info/truyentranh',$row['ep_moinhaturl']).'">'.$row['ep_moinhat'].'</a></span>
                                                        <div class="small-item-theloai " >';
														
														$vl=mangaf2_get_manga_theloai($row['theloai']);
														$str.=$vl[2].'</div>';
														$nguon=mangaf2_get_manga_nguon($row['nguon']);
														$str.='<div class="small-item-group">'.$nguon.'</div>';
												$str.='</div>
													   <div class="col-md-5">
															<div class="desc hidden-xs">
													   			<small>'.short_str($row['gioithieu'],180).'</small>
															</div>
													   </div>
													   </div><!-- End row -->			
                                                        
                                                  
												</div>';
									
									$j++;
								} // End foreach 
								$str.='</div>';
								return $str;
}
function manga_render_desktop_theloai($items){
	$cache=new cache;
	$str=$cache->load('list_anime_category2','anime');
	if(!$str){
	 $db=new db;
	 $db->connect();
	 $db->query('select * from anime_theloai  order by name asc');
	 $data=$db->fetchAll();
	
	 
	 $num=count($data);
	 $rows=ceil($num/$items);
		for($i=0;$i<$rows;$i++){
				$j=$i*$items;
				$dt=array_slice($data,$j,$items);
				$str.=' <div class="grid-column grid-column2"><ul>';
				foreach($dt as $row){
						$str.='	<li><a href="'.mangaf1_url_manga_theloai($row['id'],$row['alias']).'">'.$row['name'].'</a></li>';
					
				}
				$str.='</ul></div>';
		}
			
	$cache->save('list_anime_category2',$str,3600,'anime');	
	}
	return $str;
}
function manga_render_theloai_item($data,$type){
	if($data){
	$num=count($data);
	$rows=ceil($num/3);
	$k=1;
		for($i=0;$i<$rows;$i++){
				$j=$i*3;
				$dt=array_slice($data,$j,3);
			
			
					$str.='<div class="panel-featured-row panel-featured-row-small">';
                	
						foreach($dt as $row){
             $str.='<div class="col-md-4 col-xs-12 col-sm-12">
                    		<div class="featured-item-small">
                  						<a class="featured-item-small-a" href="#">
												<img class="featured-item-small-img img-responsive lazy" data-original="'.mangaf1_picasa_link($row['hinhanh'],100).'" alt="" style="max-width:75px" />'; 
											if($row['pick']==1){ $str.='	<span class="featured-status featured-hot">HOT</span>';}
												if($row['new']==1){ $str.='	<span class="featured-status featured-new">NEW</span>';}
								$str.='</a>';
                       
                        	$str.='<h4>';
											$str.='<a title="'.$row['name'].'" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a>';
													$str.='<span class="paragraph-end"></span>';
							$str.='</h4>';
                           $str.=' <span class="featured-item-new-chapt">
                            <a title="'.$row['name'].' '.$row['ep_moinhat'].'" href="'.str_replace('http://manga24h.com','http://truyencuatui.info/truyentranh',$row['ep_moinhaturl']).'">'.$row['ep_moinhat'].'</a><span class="paragraph-end"></span>
							</span>';
                            
                            	$str.='<div class="small-item-theloai ">'.str_replace('http://manga24h.com','http://truyencuatui.info/truyentranh',$row['theloai2']['2']).'</div>';
                                $str.='<div class="small-item-group">'.mangaf2_get_manga_nguon($row['nguon']).'</div>';
                            	$str.='</div>';
								$str.='	<div class="clear"></div>';
								$str.='</div>';
					}
					$str.='<div class="clr"></div>';
               $str.='</div>'; 
		}
		
		
		return $str;
	}else{
		return "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---
function manga_render_item($data,$type=1){
	
	if($_SESSION['mobile']!=0){
	//	render_item_truyen_mobi($data,$type);
	}else
	if($data){?>
    <?php
	$num=count($data);
	$rows=ceil($num/6);
		for($i=0;$i<$rows;$i++){
				$j=$i*6;
				$dt=array_slice($data,$j,6);
				
				?>
                
                <div class="row" style="margin-top:10px; margin-bottom:10px">
                	<?php
					foreach($dt as $row){
					?>
						<div class="col-md-2 col-sm-3 col-xs-6 each-normal-item">
                    		<div class="item_anime_box" title="<?php echo $row['name']; ?>" >
	                        	<div class="img" style="text-align:center; position:relative">
	                                                           
                                 
                                	<a href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"><img class="lazy img-responsive" data-original="<?php echo mangaf1_gglink($row['hinhanh'])?>" style="margin:auto ; width:140px; height:180px"   /></a>
                                </div>
                                <div class="item_bottom">
                                	<div class="title"><a href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></div>
                                    <div class="title2"><a href="<?php echo $row['ep_moinhaturl']; ?>"><?php echo $row['ep_moinhat']; ?></a></div>
                                </div>
                        	</div><!-- End item_truyen_box -->
                    	</div> <!-- End of col-md-3 -->
					
					<?php	
					}
					?>
                </div>
                <?php
		
		}
?>
	
<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---
function manga_render_item_slide($data,$type=1){
	
	if($_SESSION['mobile']!=0){
	//	render_item_truyen_mobi($data,$type);
	}else
	if($data){?>
    <?php
	$num=count($data);
	$rows=ceil($num/6);
		$str="";
		for($i=0;$i<$rows;$i++){
				$j=$i*6;
				$dt=array_slice($data,$j,6);
				
				
                
                $str.='<div class="row" style="margin-top:10px; margin-bottom:10px">';
                		
						foreach($dt as $row){
									
                       $str.='<div class="col-md-2 col-sm-3 col-xs-6">';
                    	  $str.='<div class="item_anime_box">';
                                     $str.=' <div class="img" style="text-align:center; position:relative">';
                              
                                	 $str.='<a href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="lazy img-responsive" src="'.mangaf1_picasa_link($row['hinhanh'],150).'" style="margin:auto; width:140px; height:180px"   /></a>';
									    $str.='</div>';
                                 $str.='<div class="item_bottom">';
                                    $str.='<div class="title"><a href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a></div>';
									 $str.='<div class="title2"><a href="'.$row['ep_moinhaturl'].'">'.$row['ep_moinhat'].'</a></div>';
                               $str.=' </div>';
                       $str.=' </div><!-- End item_truyen_box -->';
                   $str.=' </div> <!-- End of col-md-3 -->';
					
						}
						
               $str.=' </div>';
                
		
		}
		 return $str;
?>
	
<?php
	}else{
		echo "<h1 class='text-center'>Chưa có dữ liệu</h1>";
	}
} //End render item tryen ---
function manga_render_tag2($data){
		if($data['anime']){
			$row=$data['anime'];
	?>              
                <div class="row" style="background-color:#FFF" >
                	 <div class="col-md-6">
                    	<h4>Kết Qủa Tìm Kiếm Từ Khóa </h4>
                    	
                        <div class="list-group">
                        <?php 
						if($data['ep']){
							
							
						
							if(!$data['ep'][0]){
								$r1=$data['ep'];
					
								echo"	 <a href='".mangaf1_url_manga_episode($r1['id'],$r1['seourl'],$row['alias'])."' class='list-group-item'><b>".$r1['ten']."</b><span class='pull-right'>".time_ago($r1['ngaythem'])."</span> </a>";
							}else{
							  foreach($data['ep'] as $r1){
							  
							  	echo"	 <a href='".mangaf1_url_manga_episode($r1['id'],$r1['seourl'],$row['alias'])."' class='list-group-item'><b>".$r1['ten']."</b><span class='pull-right'>".time_ago($r1['ngaythem'])."</span> </a>";
							  }
							}
						}
						?>
                         
						</div>
                        
                    </div>
                	<div class="col-md-6">
                    	<div class="item2">
                  
                      
                        	<div class="item2_img pull-left" >
                            	<?php if($row['tinhtrang']==1){ echo '<span class="badge_status">'.$row['tinhtrang-text'].'</span>';}?>
                           
                           <img class="lazy img-responsive" data-original="<?php echo mangaf1_gglink($row['hinhanh'])?>" style="margin:auto; width:75px; height:110px"   />
                           </div>
                            <div class="item2_data">
                            		<h2><a href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></h2>
                                 
                                    <div class="item2_theloai"><?php echo $row['theloai2']['2']; ?></div>
                                    
                              
                                     <div class="item2_ep"> <a href="<?php echo $row['ep_moinhaturl'] ?>"><?php echo $row['ep_moinhat']; ?></a> &nbsp;&nbsp;
                                     <?php echo time_ago($row['ep_ngaythem']); ?>
                                     </div>
                                      <div class="item2_ep"><i class="fa fa-heart"></i> <?php echo $row['thanks'] ?> &nbsp;&nbsp; <i class="fa fa-eye"></i> <?php echo $row['views'] ?>                           
                                     </div>
                                
                            </div>
                            <div class="clearfix"></div>
                            
                            <div style="color:#999; font-size:11px"><?php echo short_str($row['noidung'],300) ?></div>
                        </div> <!-- End of item2 -->
                    </div><!-- End col md 6 -->
                   
                 
					
					
                </div>
                <?php
		}else//
		{
			echo "<h1 class='alert alert-warning'>Không có kết quả nào được tìm thấy</h1>";
		}
} //End render item tryen ---
function manga_render_tag($data){
		if($data['anime']){
			$row=$data['anime'];
	?>              
                <div class="row" style="background-color:#FFF" >
                	
                	<div class="col-md-6">
                    	<div class="item2">
                  
                         <div class="badge_ep"><?php echo $row['item_ep_max']." / ".$row['tongsoep']; ?></div>
                        	<div class="item2_img pull-left" >
                            	<?php if($row['tinhtrang']==1){ echo '<span class="badge_status">'.$row['tinhtrang-text'].'</span>';}?>
                               <?php if($row['new']==1){echo ' <div class="ribbon ribbon_new"></div>';}?>
                               <?php if($row['pick']==1){echo ' <div class="ribbon ribbon_hot"></div>';}?>
                           <img class="lazy img-responsive" data-original="<?php echo gglink($row['hinhanh'])?>" style="margin:auto"   />
                           </div>
                            <div class="item2_data pull-left">
                            		<h2><a href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></h2>
                                 
                                    <div class="item2_theloai"><?php echo $row['theloai2']['2']; ?></div>
                                    <?php if($row['item_ep']){
										echo '  <div class="item2_ep"><a href="'.$row['item_ep']['url'].'">';
										echo $row['item_ep']['title'];
										echo '</a>';
										echo ' <span class="item2_time" >'.time_ago($row['item_ep']['time_update']).'</span>';
										echo '</div>';
									}?>
                                
                                    <div class="item2_fansub"><i class="fa fa-comment"></i><?php echo $row['comments']; ?>  &nbsp;&nbsp;<i class="fa fa-eye"></i> <?php echo $row['views']; ?> </div>
                            </div>
                            <div class="clearfix"></div>
                            
                            <div style="color:#999; font-size:11px"><?php echo $row['gioithieu'] ?></div>
                        </div> <!-- End of item2 -->
                    </div><!-- End col md 6 -->
                    <div class="col-md-6">
                    	<h4>Episode Mới Nhất của anime <b><?php echo $data['anime']['name'] ?></b> </h4>
                    	
                        <div class="list-group">
                        <?php 
						if($data['ep'])
						foreach($data['ep'] as $r1){
						echo"	 <a href='".$r1['ep']['url']."' class='list-group-item'><b>[".$r1['fansub']['name']."]</b> ".$row['name']." ".$r1['ep']['title']." </a>";
						}?>
                         
						</div>
                        
                    </div>
                 
					
					
                </div>
                <?php
		}else//
		{
			echo "<h1 class='alert alert-warning'>Không có kết quả nào được tìm thấy</h1>";
		}
} //End render item tryen ---
//End render item tryen ---
function manga_render_box($data){
?>
   <div class="row" itemscope itemtype="http://schema.org/book"> <!-- Start anime info box -->
             
            		<div class="col-md-3 col-sm-3 col-xs-12">
                    	<div class="item_truyen_box" style="text-align:center">
                        		   <?php if($_SESSION['mobile']!=0){?>
                                    <h1 class="name" itemprop='name'><span style="line-height:30px"><?php echo $data['name'] ?></span></h1>
									<?php }?>
                                <div class="img">
                                	  <a itemprop="url" href="<?php echo mangaf1_url_manga($data['id'],$data['alias']) ?>"><img itemprop='image' src="<?php echo gglink($data['hinhanh']) ?>" class="img-rounded img-responsive" /></a>
                                </div>
                                        <div id="wrap-rating" class="rating" xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate">
                                	<h3 style="font-size: 12px; line-height: 18px;" property="v:itemreviewed"><?php echo $data['name'] ?></h3>
                                	<div id="truyen-rating" style="margin: 0px auto;" class="basic" data-average="<?= $data['rate_average']; ?>" data-id="1"></div>
                                	
					   				<span rel="v:rating">
						   				<p id="rating-point" typeof="v:Rating">
						   					<span property="v:average"><?= $data['rate_average']; ?></span> / 
	         								<span property="v:best">5</span> 
	         								<p><span property="v:count"><?= $data['rate_count'] ?></span> lượt đánh giá</p>
	         							</p>
	         							
	         						</span>
         							<p style="display: none; margin-top: 3px;" id="rate_message"></p>
         							
         							
					   				
                                </div>
								<!-- JS to add -->
								<script type="text/javascript">
								  $(document).ready(function(){
									rateDisable = false;
									if($.cookie('ranime_<?php echo $data['id']; ?>') == '1'){
					
										rateDisable = true;
									}
									  
									$(".basic").jRating({
										bigStarsPath : '<?php echo HOME ?>public/images/stars.png', // path of the icon stars.png
										smallStarsPath : '<?php echo HOME ?>public/images/small.png', // path of the icon small.png
										type:"big",
										length : 5,
										decimalLength : 1,
										isDisabled: rateDisable,
										step: true,
										nbRates : 3,
										rateMax : 5,
										showRateInfo:false,
										phpPath : '<?= HOME; ?>index.php?module=ajax&act=ajax&rating=1&act=anime&id=<?= $data['id']; ?>',
										
										onSuccess : function(data){
											
											if(data){
												if(data.type == 'success'){
													classMsgRating = 'rate_success';
													$.cookie('ranime_<?php echo $data['id']; ?>', '1', { expires: 30 });
												}else if(data.type == 'error'){
													classMsgRating = 'rate_error';
												}
												
												$('#rate_message').html('<p class="'+classMsgRating+'">'+data.message+'</p>');
												$('#rate_message').slideDown('normal').delay(3000).slideUp('normal');
											}
											
										  },
										
									});
								  });
								</script>
                                  <div class="btn-group-vertical" >
      
        <a class="btn btn-info btn-sm follow-story" role="button">Theo Dõi Manga  Này  </a>	
       
        
        </div>
                              	
                        </div><!-- End item_truyen_box -->
                    </div> <!-- End of col-md-3 -->
                      
                    <div class="col-md-9 col-sm-9 col-xs-12">
                     <?php if($_SESSION['mobile']==0){?> <h1 class="name" itemprop='name'><?php echo $data['name'] ?></h1><?php }?>
                                                                      
                    <div class="item_truyen_detail" style="background-color:#fafafa; border-radius:5px; margin-top:10px">
                   
<ul class="nav nav-tabs" id="truyen_detail">
  <li class="active"><a href="#truyen_thongtin" data-toggle="tab" >Thông Tin</a></li>
 
  <li><a href="#truyen_tags" data-toggle="tab"> Tags</a></li>
</ul>
<div class="tab-content truyen_thongtin_tab" style="background:#fff">
  <div class="tab-pane fade in active" id="truyen_thongtin">
  <table class="table" id="truyen_detail_metadata">
                    		<tr>
                    			<td class="theloai" width="120" align="left">Thể Loại:</td>
                    			<td class="theloai"><?php echo $data['theloai2']['2']; ?></td>
                    		</tr>
                            <tr>
                    			<td class="theloai" width="120" align="left">Tác giả :</td>
                    			<td class="theloai"><?php echo $data['tacgia']; ?></td>
                    		</tr>
                    		<tr>
                    			<td class="tinhtrang" align="left">Tình Trạng:</td>
                    			<td class="tinhtrang"><span><?php echo $data['tinhtrang-text']; ?></span></td>
                    		</tr>
                            <tr>
                    			<td class="tinhtrang" align="left">Nguồn</td>
                    			<td class="nguon"><span><?php if($data['nguon']!=''){ echo $data['nguon'];}else{ echo "Đang cập nhật ...";} ?></span></td>
                    		</tr>
                    		<tr>
                    			<td class="view" align="left">Lượt Xem:</td>
                    			<td class="view"><span class="badge"><?php echo $data['views']; ?></span></td>
                    		</tr>
                            <tr>
                    			<td class="view" align="left">Ngày Đăng:</td>
                    			<td class="view"><span class="badge"><?php echo time_ago($data['upload_time']); ?></span></td>
                    		</tr>
                            
                    			
                           
                    	
                    		
                       
                    	</table>
               
  </div>
 
   					
  
       <div class="tab-pane fade" id="truyen_tags"> 
        <?php echo $data['data_tags']; ?>
         <?php echo $data['tag3']; ?>
       </div>
  
 
</div> <!-- End tab-content -->
 					<div class="noidung" itemprop='description'>
    					 <?php 
              		if($data['noidung']==''){
							$content_show = $data['gioithieu'];
							
						}else{
							$content_show = $data['noidung'];
						}
						echo $content_show;
						?>
                         
                         </div>
             </div><!-- End truyen detail-->
                    </div> <!-- End of col-md-9 -->
                   
      </div> <!-- End of  Row anime info case -->
      <input type="hidden" name="anime_id" id="anime_id" value="<?php echo $data['id']; ?>" />
<?php }
 
 //MANGA RENDER FUNCTION
  function manga_render_update($data){
	 
 ?>
    <table class="table  table_manga" style="text-align:left">
                  <?php
				  foreach ($data as $row)
				   {?>
              
                    <thead>
                <tr >
                 		
                        <th colspan="2"><div class="ngay_update"> <?php  if($row['ngay']==date('Y-m-d')){?><span class="case1"> Manga Cập Nhật Hôm Nay <?php }else{?>   
				 <span class="case2"> <?php echo time_ago($row['ngay']);?><?php }?></span>
                  	</div>
                  </th>		
       </tr>
              </thead>
              	<tbody>
                   					<?php 
									
									foreach($row['data'] as $row){
									?>
                     <tr>
            <td>
            
            <a class="mg_name"   href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"> <?php echo $row['name'] ?></a></td>
            <td>  <a class="mg_chapter" href="<?php echo  mangaf1_url_manga_episode($row['chapid'],$row['seourl'],$row['alias']) ?>"><?php  echo $row['index_show']?></a> 
                 	<?php if($row['hot']==1){?><span class="label label-danger"> HOT </span> <?php }?>
                      <?php if($row['new']==1){?><span class="label label-warning"> NEW </span> <?php }?>
                    </td>
             
          </tr>
                   					<?php } ?>
                       </tbody>             
                   
                   <?php
				   }
				   ?>
           
            </table>
            
                       
                        
                
                   <?php
 } //End of manga render update
 
   function manga_render_update2($data){
	 
 ?>
            
                  <table class="table  table_manga" style="text-align:left">
     				<?php	
						foreach($data as $row){
					?>
                     <tr>
            <td>
            
            <a class="mg_name"   href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"> <?php echo $row['name'] ?></a></td>
            <td>  <a class="mg_chapter" href="<?php echo  mangaf1_url_manga_episode($row['chapid'],$row['seourl'],$row['alias']) ?>"><?php  echo $row['ten']?></a> 
                 	<?php if($row['hot']==1){?><span class="label label-danger"> HOT </span> <?php }?>
                      <?php if($row['new']==1){?><span class="label label-warning"> NEW </span> <?php }?>
                    </td>
             
          </tr>
                   					<?php } ?>
                    
           
            </table>
            
                       
                        
                
                   <?php
 } //End of manga render update
 
 
    function manga_render_update3($data){
	 
 ?>
            
                  <table class="table  table_manga" style="text-align:left">
     				<?php	
						foreach($data as $row){
					?>
                     <tr>
            <td>
            
            <a class="mg_name"   href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"> <?php echo $row['name'] ?></a></td>
            <td>  <a class="mg_chapter" href="<?php echo $row['ep_moinhaturl']; ?>"><?php  echo $row['ep_moinhat']?></a> 
               
                    </td>
             
          </tr>
                   					<?php } ?>
                    
           
            </table>
            
                       
                        
                
                   <?php
 } //End of manga render update
 
 
function manga_render_group_item_pick(){
	$data= mangaf2_get_pick();
	if($data){
	$str= "<div class='list-group'>";
			$j=1;
			foreach($data as $row){
					if($j%2==0){
											   $str.='<div class="each-small-item item-even">';
										}else{
												$str.='<div class="each-small-item item-odd">';
										}
													$str.='	<a class="small-image-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="img-right lazy2" data-original="'.mangaf1_picasa_link($row['hinhanh'],70).'" alt="" /></a>
														<a class="small-title-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a>
														<span class="featured-item-new-chapt"><a href="'.str_replace('http://manga24h.com','http://truyencuatui.info/truyentranh',$row['ep_moinhaturl']).'">'.$row['ep_moinhat'].'</a></span>
                                                        <div class="small-item-theloai " >';
														
														$vl=mangaf2_get_manga_theloai($row['theloai']);
														$str.=$vl[2].'</div>';
														$nguon=mangaf2_get_manga_nguon($row['nguon']);
														$str.='<div class="small-item-group">'.$nguon.'</div>
                                                        
                                                        <div class="clr"></div>
												</div>';
									
									$j++;
							
				
			} // End foreach 
		
		$str.='</div>';
		return $str;
	} else{// End !$data
		return  "<h4>Chưa có dữ liệu</h4>";
	}
}

function manga_render_group_item_new(){
	$data= mangaf2_get_new();
	if($data){
	$str= "<div class='list-group'>";
			$j=1;
			foreach($data as $row){
					if($j%2==0){
											   $str.='<div class="each-small-item item-even">';
										}else{
												$str.='<div class="each-small-item item-odd">';
										}
													$str.='	<a class="small-image-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'"><img class="img-right lazy" data-original="'.mangaf1_picasa_link($row['hinhanh'],100).'" alt="" /></a>
														<a class="small-title-item" href="'.mangaf1_url_manga($row['id'],$row['alias']).'">'.$row['name'].'</a>
														<span class="featured-item-new-chapt"><a href="'.$row['ep_moinhaturl'].'">'.$row['ep_moinhat'].'</a></span>
                                                        <div class="small-item-theloai " >';
														
														$vl=mangaf2_get_manga_theloai($row['theloai']);
														$str.=$vl[2].'</div>';
														$nguon=mangaf2_get_manga_nguon($row['nguon']);
														$str.='<div class="small-item-group">'.$nguon.'</div>
                                                        
                                                        <div class="clr"></div>
												</div>';
									
									$j++;
							
				
			} // End foreach 
		
		$str.='</div>';
		return $str;
	} else{// End !$data
		return  "<h4>Chưa có dữ liệu</h4>";
	}
}
 
 
 

 
 
  function manga_render_right_comment()
 {
	 ?>
     	<div class="right-section" id="right-comment">
								<div class="right-title">
									<span class="right-title-span">Mới bình luận</span>
									<span class="right-title-span-after"></span>
								</div>
								<div class="right-content">
								 <?php
                                 $str=mangaf2_get_comment();
                                 echo $str;
                                 ?>
     
                            	</div>
							</div><!-- /#right-comment -->
                            <!-- END COMMENT -->
     <?php
 }	
 
 function manga_mobi_render_right_comment()
 {
 	?>
      	<div class="right-section" id="right-comment">
 								<div class="right-title">
 									Mới bình luận
 									
 								</div>
 								<div class="right-content">
 								 <?php
                                  $str=mangaf2_get_comment();
                                  echo $str;
                                  ?>
      
                             	</div>
 							</div><!-- /#right-comment -->
                             <!-- END COMMENT -->
      <?php
  }	
 
 
 
 function manga_render_search(){
		if($_SESSION['mobile']==0){
		echo '	<div style="text-align:center"><input type="hidden" name="optionvalue" id="menu-search-box" class="input-medium" data-placeholder="Nhập Tên Manga ..."   /></div><Br/>';
		// echo '<div class="panel panel-info ">  <div class="panel-body box_news"><div class="fb-like-box" data-href="'.FB_FANPAGE.'"  data-colorscheme="light" data-show-faces="true" data-header="false" data-stream="false" data-show-border="false"></div></div></div>';
		}
 }
 
 function manga_render_slider(){
	$cache=new cache;
	$sd=$cache->load("slide","home");
	if(!$sd){
		$db=new db;
		$db->connect();
		$db->query("select * from slide where ok=1 order by thutu asc limit 0,4");
		if($db->num_rows()>0){
			$sd=$db->fetchAll();
			$cache->save("slide",$sd,500,"home");
		}
		$db->close();
	}
	
		if($sd){
	?>
    			<div id="wrap-top-content" class="row">
				<ul class="bxslider" id="main-slider">
                <?php foreach($sd as $row){?>
					<li><a href="<?php echo $row['link'];?>"><img src="<?php echo HOME."images/banner/".$row['image'];?>" title="<?php echo $row['title'];?>" /></a></li>
                    <?php } ?>
					
				</ul>
				<div id="bx-pager">
                 <?php
				 	$j=0;
				  foreach($sd as $row){?>
				     <a data-slide-index="<?php echo $j++?>;" href=""><img width="80" height="40" src="<?php echo HOME."images/banner/thumb/".$row['image'];?>" /></a>
                    <?php } ?>
					
				
				</div>
				<script type="text/javascript">
					$('.bxslider').bxSlider({
						mode: 'fade',
						//captions: true
						pagerCustom: "#bx-pager",
						pager: true,
						auto: true,
					});
				</script>
			</div><!-- end #wrap-top-content -->	
    <?php
	} // if sd
 }
 
  function manga_render_slider2(){
	$cache=new cache;
	$sd=$cache->load("slide","home");
	if(!$sd){
		$db=new db;
		$db->connect();
		$db->query("select * from anime_slider where status=1 order by thutu asc limit 0,4");
		if($db->num_rows()>0){
			$sd=$db->fetchAll();
			$cache->save("slide",$sd,500,"home");
		}
		$db->close();
	}
	
		if($sd){
			echo '<div id="example5" class="slider-pro" style="visibility:hidden;">
					<div class="sp-slides">';
			 foreach($sd as $row){
	?>
			<div class="sp-slide">
				<a href="<?php echo $row['url'];?>">
				<img class="sp-image lazy" src="<?php echo HOME; ?>public/exts/css/images/blank.gif"
					data-src="<?php echo HOME."images/slider/".$row['image'];?>"
					data-retina="<?php echo HOME."images/slider/".$row['image'];?>" />
				
				<h2 class="sp-layer sp-black sp-padding" style="color: #A4C514;"
					data-position="bottomLeft" data-vertical="70" data-horizontal="5%" data-width="" 
					data-show-transition="down" data-show-delay="200" data-hide-transition="down"><?php echo $row['name'];?> </h2>
				<p class="sp-layer sp-black sp-padding" 
					data-position="bottomLeft" data-vertical="10" data-horizontal="5%" data-width="90%" 
					data-show-transition="up" data-show-delay="600" data-hide-transition="down">
					<?php echo $row['gioithieu'];?>
				</p>
                </a>
			</div>
	  
  <?php }
   echo '</div>
		
		<div class="sp-thumbnails">'; 
   foreach($sd as $row){
	?>
		<div class="sp-thumbnail">
				<div class="sp-thumbnail-image-container">
					<img class="sp-thumbnail-image" src="<?php echo HOME."images/slider/thumb/".$row['image'];?>" />
				</div>
				
			</div>
	<?php 
	}
   echo '</div></div>'; ?>
          
       <script type="text/javascript">
        	$( document ).ready(function() {
				$('#example5').css('visibility', 'visible');
            	
        		$( '#example5' ).sliderPro({
        			width: 900,
        			height: 290,
        			orientation: 'horizontal',
        			loop: true,
        			arrows: true,
        			buttons: false,
        			thumbnailsPosition: 'right',
        			thumbnailPointer: true,
        			autoplay: true,
        			thumbnailWidth: 300,
        			thumbnailHeight: 100,
        			breakpoints: {
        				600: {
        					thumbnailsPosition: 'right',
        					thumbnailWidth: 270,
        					thumbnailHeight: 100
        				},
        				500: {
        					thumbnailsPosition: 'right',
        					thumbnailWidth: 120,
        					thumbnailHeight: 50
        				}
        			}
        		});
        		
        	});
        	
        </script>
    <?php
	} // if sd
 }
 
 //Render tag result -------------
 
function manga_render_manga_tag2($data){
		if($data['anime']){
			$row=$data['anime'];
	?>              
                <div class="row" style="background-color:#FFF ; margin:0px">
                	 <div class="col-md-6">
                    	<h4>Kết Qủa Tìm Kiếm Từ Khóa </h4>
                    	
                        <div class="list-group">
                        <?php 
						if($data['ep']){
							
							
						
							if(!$data['ep'][0]){
								$r1=$data['ep'];
					
								echo"	 <a href='".mangaf1_url_manga_episode($r1['id'],$r1['seourl'],$row['alias'])."' class='list-group-item'><b>".$r1['ten']."</b><span class='pull-right'>".time_ago($r1['ngaythem'])."</span> </a>";
							}else{
							  foreach($data['ep'] as $r1){
							  
							  	echo"	 <a href='".mangaf1_url_manga_episode($r1['id'],$r1['seourl'],$row['alias'])."' class='list-group-item'><b>".$r1['ten']."</b><span class='pull-right'>".time_ago($r1['ngaythem'])."</span> </a>";
							  }
							}
						}
						?>
                         
						</div>
                        
                    </div>
                	<div class="col-md-6">
                    	<div class="item2">
                  
                      
                        	<div class="item2_img pull-left" >
                            	<?php if($row['tinhtrang']==1){ echo '<span class="badge_status">'.$row['tinhtrang-text'].'</span>';}?>
                           
                           <img class="lazy img-responsive" data-original="<?php echo gglink($row['hinhanh'])?>" style="margin:auto; width:75px; height:110px"   />
                           </div>
                            <div class="item2_data" style="line-height:20px">
                            		<div><a href="<?php echo mangaf1_url_manga($row['id'],$row['alias']) ?>"><?php echo $row['name']; ?></a></div>
                                 
                                    <div class="item2_theloai"><?php echo $row['theloai2']['2']; ?></div>
                                    
                              
                                     <div class="item2_ep"> <a href="<?php echo $row['ep_moinhaturl'] ?>"><?php echo $row['ep_moinhat']; ?></a> &nbsp;&nbsp;
                                     <?php echo time_ago($row['ep_ngaythem']); ?>
                                     </div>
                                      <div class="item2_ep"><i class="fa fa-heart"></i> <?php echo $row['thanks'] ?> &nbsp;&nbsp; <i class="fa fa-eye"></i> <?php echo $row['views'] ?>                           
                                     </div>
                                
                            </div>
                            <div class="clearfix"></div>
                            
                            <div style="color:#000; font-size:13px"><?php echo short_str($row['noidung'],300) ?></div>
                        </div> <!-- End of item2 -->
                    </div><!-- End col md 6 -->
                   
                 
					
					
                </div>
                <?php
		}else//
		{
			echo "<h1 class='alert alert-warning'>Không có kết quả nào được tìm thấy</h1>";
		}
} 

function manga_render_fansub_box($data){
				$str.='<span class="right-block-title">Thông tin nhóm dịch</span>';
				$str.='<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">';
					$str.='<!-- Wrapper for slides -->';
					$str.='<div class="carousel-inner" role="listbox">';
						$k=0;
						foreach($data as $val){
							if($k==0){$str.='<div class="item active" style="background: #fafafa">';}else{$str.='<div class="item " style="background: #fafafa">';}
							$str.='<div class="author-carous">';
								$str.='<img class="author-carous-avatar" alt="" src="'.$val['hinhanh'].'" /> ';
								$str.='<a href="'.$val['url'].'" class="author-carous-name">'.$val['name'].'</a>';
								$str.='<p class="author-carous-links">';
									$str.='<a style="width: 100px" href="'.$val['trangchu'].'">Trang chủ</a>';
									$str.='<a href="'.$val['facebook'].'">Facebook</a><br />';
									$str.='<a style="width: 100px" href="'.$val['dangky'].'">Tham gia</a>';
									$str.='<a href="'.$val['url'].'">Truyện của nhóm</a>';
								$str.='</p>';
								$str.='<div class="clr"></div>';
								$str.='<p class="author-carous-des">'.$val['gioithieu'].'</p>';
								$str.='<a href="#" class="pull-right author-edit-profile" rel="'.$val['id'].'"><i class="fa fa-edit"></i> Sửa thông tin</a>';
								$str.='<div class="clr"></div>';
							$str.='</div>';
						$str.='</div>';
						$k++;
						
					}
					
					
					if(count($data)>1){
					$str.='<!-- Controls -->';
					$str.='<a class="left carousel-control" href="#carousel-example-generic"';
					$str.='	role="button" data-slide="prev"> <span ';
						$str.='class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>';
					$str.='	<span class="sr-only">Previous</span>';
					$str.='</a> <a class="right carousel-control"';
					$str.='	href="#carousel-example-generic" role="button" data-slide="next">';
						$str.='<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>';
						$str.='<span class="sr-only">Next</span>';
					$str.='</a>';
					}
				$str.='</div><!-- .carousel-inner -->';
			$str.='</div><!-- .carousel-example-generic -->';
			return $str;

}
//End render item tryen ---
